package bishe;

import java.io.*;
import java.util.ArrayList;

class Goods {

	public Goods() {

	}

	public static void add(String a, String b, String c,String d) throws IOException {
		// TODO 自动生成的方法存根	
		StringBuilder ts = new StringBuilder();
		ts.append(a + " " + b + " " + c+" "+d);
		BufferedWriter out = new BufferedWriter(new FileWriter("Goods.txt", true));
		out.append(ts);
		out.newLine();
		out.close();
	}

	public static void remove(String goods) throws IOException {
		ArrayList<String> list = new ArrayList<String>();
		BufferedReader in = new BufferedReader(new FileReader("Goods.txt"));
		String str = null;
		while ((str = in.readLine()) != null) {
			if (str.matches("(.*)" + goods + "(.*)")) {
				continue;
			} else {
				list.add(str);
			}
		}
		in.close();
		BufferedWriter out = new BufferedWriter(new FileWriter("Goods.txt"));
		for (int i = 0; i < list.size(); i++) {
			out.append(list.get(i));
			out.newLine();
		}
		out.close();
	}
}